
<#assign _type = "${RequestParameters['type']}" />
<@t.plat_body pageid="infos_${_type}">

<script type="text/javascript" src="${base}/js/plugins/uploaders/plupload/plupload.full.min.js"></script>
<script type="text/javascript" src="${base}/js/plugins/uploaders/plupload/plupload.queue.min.js"></script>
<script type="text/javascript" src="${base}/js/plugins/uploaders/plupload/i18n/zh_CN.js"></script>
<style>
    .plupload_filelist:empty:after, .plupload_filelist li.plupload_droptext:after{
        content:'把文件拖到这里'
    }
</style>

<div class="panel border-top-primary" style="margin: 0">
    <div class="page-header" style="margin: 0">
        <div class="breadcrumb-line breadcrumb-line-wide border-top-primary">
            <ul class="breadcrumb">
                <#if _type=='1'>
                    <li><a href="${base}/plat/info/infos?type=${_type}"><i class="icon-arrow-left52 position-left"></i>学生管理</a></li>
                <#else>
                    <li><a href="${base}/plat/info/infos?type=${_type}"><i class="icon-arrow-left52 position-left"></i>教师管理</a></li>
                </#if>

                <li class="active">批量导入</li>
            </ul>
        </div>
    </div>
</div>


<div class="content">


    <div class="panel panel-flat">
        <div class="panel-heading">
            <h5 class="panel-title">批量导入</h5>
            <div class="heading-elements">
                <#if _type=='1'>
                    <a style="margin-left: 2px" class="btn btn-danger btn-xs btn-outline" target="_blank" download="stu_template.xlsx" href="${base}/res/stu_template.xlsx">模板下载</a>
                <#else>
                    <a style="margin-left: 2px" class="btn btn-danger btn-xs btn-outline" target="_blank" download="teacher_template.xlsx" href="${base}/res/teacher_template.xlsx">模板下载</a>
                </#if>

            </div>
        </div>


        <div class="panel-body">
            <#if _type=='1'>
                <form class="form-horizontal" id="qForm">
                    <div class="form-group">
                        <label class="control-label col-xs-1">所属班级*</label>
                        <div class="col-lg-9">
                            <select name="classid" class="form-control" id="classid" style="width: 300px">
                                <#list clazz as m>
                                    <option value="${m.id}">${m.name}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                </form>
            </#if>

            <div>
                <div class="file-uploader"></div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        var data={};
        var index=0;
        data.firstRow=3;
        data.name=index++;//姓名
        data.sno=index++;//是否毕业
        data.password=index++;//是否毕业
        data.idno=index++;//是否毕业
        data.email=index++;//是否毕业
        data.mobile=index++;//是否毕业
        data.zy=index++;//是否毕业
        data.dept=index++;//是否毕业
        data.pid=index++;//是否毕业
        data.type='${_type}';
        plupload.addI18n({
            'Add Files': '选择文件',
            'Start Upload': '开始导入'
        });

        $(".file-uploader").pluploadQueue({
            runtimes: 'html5, html4, Flash, Silverlight',
            url: '${base}/pl/info/import_infos',
            chunk_size: '300Kb',
            unique_names: true,
            multi_selection:false,
            filters: {
                max_file_size: '100mb',
                mime_types: [{
                    title: "Excel文件",
                    extensions: "xls,xlsx"
                }]
            },
            multipart_params:data,
            init:{
                BeforeUpload:function (uploader, file) {
                    data.classid=$('#classid').val();
                    uploader.multipart_params=data;
                },
                FilesAdded : function(uploader, file){
                    <#if _type=='1'>
                        if(checkForm($('#qForm'))===false){
                            if(uploader.files.length>0) {
                                uploader.removeFile(uploader.files[uploader.files.length-1]);
                            }
                            return;
                        }
                    </#if>

                    if(uploader.files.length>1) { // 最多上传3张图
                        uploader.removeFile(uploader.files[uploader.files.length-1]);
                        return;
                    }
                },
                FileUploaded : function(up, file, info) {//文件上传完毕触发
                    var response = $.parseJSON(info.response);
                    if(response.code==0){
                        alertError('操作成功');
                    }else{
                        if(response.code==4000){
                            var l=parent.layer;
                            if(!l){
                                l=layer;
                            }
                            l.msg(response.message+'，点击下载详情<a href="${base}/pl/info/download/batch/result" style="color: #4fc3f7;font-style: normal" id="saveys-number">下载</a><button type="button" onclick="layer_close_all()">关闭</button>', {
                                icon: 16
                                ,time:1000000000
                                ,shade: [0.3,'#000000']
                            });

                        }else{
                            alertError('文件上传失败');
                        }

                    }

                }
            }
        });


    });




</script>
</@t.plat_body>